package com.itxiuyixiu.contoller;

import com.itxiuyixiu.service.EmailService;
import com.itxiuyixiu.tools.util.returns.ReturnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;

/**
 * @author 黄磊
 * @date 2020/5/21
 */
@RestController
public class EmailController {
    @Autowired
    private EmailService emailService;

    @PostMapping("/verification")
    public ReturnVo sendVerification(@RequestParam String email) {
        if (!emailService.sendVerification(email)) {
            return ReturnVo.getFailureReturn("发送邮件失败，请稍后重新尝试");
        }
        return ReturnVo.getSuccessReturn("发送验证码成功");
    }
}
